package com.appistry.storage;


import java.io.FileInputStream;
import java.util.List;

import com.appistry.api.util.Version;

public class StorageManagerClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
//		System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
//		System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
//		System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire.header", "debug");
//		System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient", "debug");

		StorageManager manager = new StorageManager("fabric-admin", "fabric-admin", "worker00", Version.CLOUDIQ_42);
		Storage storage = manager.getStorage();
		
//		storage.putFile("helloworld", new FileInputStream("/usr/local/test.txt"));
//		File myFile = storage.getFileRef("/myFile.txt");
//		System.out.println("File Name: " + myFile);
//		System.out.println("Locations: " + myFile.getLocations());
		
		List<File> files = storage.getFiles("/");
//		System.out.println(storage.getWorkers(true));
		for(File file : files){			
			if(file.isDir()){
//				System.out.println("DIR: " + file);				
			}else{
				System.out.println("FILE: " + file);
				System.out.println("  Locations: " + file.getLocations());
				file.getFileMetaData();
				
//				storage.moveFile(file.getPath(), file.getPath() + " space");
			}
//			
////			System.out.println("\tNAME: " + file.getName());
////			System.out.println("\tPARENT: " + file.getParent());
////			System.out.println("\tPATH: " + file.getPath());
////			
		}
		
		for(Worker w: storage.getWorkers()){
			WorkerInfo info = w.getWorkerInfo();
			WorkerConfiguration config = w.getWorkerConfiguration();
			System.out.println("info: " + info.getMacAddress());
			System.out.println("config: " + config.getMountPath());
			
		}
	}

}
